home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / AttributeSet.java < prev    next >
Text File  |  1998-06-30  |  6KB  |  176 lines

  1. /*
  2.  * @(#)AttributeSet.java    1.24 98/04/09
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.text;
  21.  
  22. import java.util.Enumeration;
  23.  
  24. /**
  25.  * A collection of unique attributes.  This is a read-only, 
  26.  * immutable interface.  An attribute is basically a key and
  27.  * a value assigned to the key.  The collection may represent
  28.  * something like a style run, a logical style, etc.  These
  29.  * are generally used to describe features that will contribute
  30.  * to some graphical representation such as a font.  The
  31.  * set of possible keys is unbounded and can be anything.
  32.  * Typically View implementations will respond to attribute
  33.  * definitions and render something to represent the attributes.
  34.  * <p>
  35.  * Attributes can potentially resolve in a hierarchy.  If a 
  36.  * key doesn't resolve locally, and a resolving parent
  37.  * exists, the key will be resolved through the parent.
  38.  *
  39.  * @author  Timothy Prinzing
  40.  * @version 1.24 04/09/98
  41.  * @see MutableAttributeSet
  42.  * @see AttributeCharacterIterator
  43.  */
  44. public interface AttributeSet {
  45.  
  46.     /**
  47.      * This interface is the type signature that is expected
  48.      * to be present on any attribute key that contributes to
  49.      * the determination of what font to use to render some 
  50.      * text.  This is not considered to be a closed set, the 
  51.      * definition can change across version of the JDK and can 
  52.      * be ammended by additional user added entries that 
  53.      * correspond to logical settings that are specific to
  54.      * some type of content.
  55.      */
  56.     public interface FontAttribute {
  57.     }
  58.  
  59.     /**
  60.      * This interface is the type signature that is expected
  61.      * to be present on any attribute key that contributes to
  62.      * presentation of color.
  63.      */
  64.     public interface ColorAttribute {
  65.     }
  66.  
  67.     /**
  68.      * This interface is the type signature that is expected
  69.      * to be present on any attribute key that contributes to
  70.      * character level presentation.  This would be any attribute
  71.      * that applies to a so-called <term>run</term> of 
  72.      * style.
  73.      */
  74.     public interface CharacterAttribute {
  75.     }
  76.  
  77.     /**
  78.      * This interface is the type signature that is expected
  79.      * to be present on any attribute key that contributes to
  80.      * the paragraph level presentation.
  81.      */
  82.     public interface ParagraphAttribute {
  83.     }
  84.  
  85.     /**
  86.      * Returns the number of attributes contained in this set.
  87.      *
  88.      * @return the number of attributes >= 0
  89.      */
  90.     public int getAttributeCount();
  91.  
  92.     /**
  93.      * Checks whether the named attribute has a value specified in
  94.      * the set without resolving through another attribute
  95.      * set.
  96.      *
  97.      * @param attrName the attribute name
  98.      * @return true if the attribute has a value specified
  99.      */
  100.     public boolean isDefined(Object attrName);
  101.  
  102.     /**
  103.      * Determines if the two attribute sets are equivalent.
  104.      *
  105.      * @param attr an attribute set
  106.      * @return true if the sets are equivalent
  107.      */
  108.     public boolean isEqual(AttributeSet attr);
  109.  
  110.     /**
  111.      * Returns an attribute set that is guaranteed not
  112.      * to change over time.  
  113.      *
  114.      * @return a copy of the attribute set
  115.      */
  116.     public AttributeSet copyAttributes();
  117.  
  118.     /**
  119.      * Fetches the value of the given attribute. If the value is not found
  120.      * locally, the search is continued upward through the resolving 
  121.      * parent (if one exists) until the value is either
  122.      * found or there are no more parents.  If the value is not found,
  123.      * null is returned.
  124.      *
  125.      * @param key the non-null key of the attribute binding
  126.      * @return the value
  127.      */
  128.     public Object getAttribute(Object key);
  129.  
  130.     /**
  131.      * Returns an enumeration over the names of the attributes in the set.
  132.      * The elements of the enumeration are all Strings.  The set does
  133.      * not include the resolving parent, if one is defined.
  134.      *
  135.      * @return the names
  136.      */
  137.     public Enumeration getAttributeNames();
  138.  
  139.     /**
  140.      * Returns true if this set contains this attribute with an equal value.
  141.      *
  142.      * @param name the non-null attribute name
  143.      * @param value the value
  144.      * @return true if the set contains the attribute with an equal value
  145.      */
  146.     public boolean containsAttribute(Object name, Object value);
  147.  
  148.     /**
  149.      * Returns true if this set contains all the attributes with equal values.
  150.      *
  151.      * @param attributes the set of attributes to check against
  152.      * @return true if this set contains all the attributes with equal values
  153.      */
  154.     public boolean containsAttributes(AttributeSet attributes);
  155.  
  156.     /**
  157.      * Gets the resolving parent.
  158.      *
  159.      * @return the parent
  160.      */
  161.     public AttributeSet getResolveParent();
  162.  
  163.     /**
  164.      * Attribute name used to name the collection of
  165.      * attributes.
  166.      */
  167.     public static final Object NameAttribute = StyleConstants.NameAttribute;
  168.  
  169.     /**
  170.      * Attribute name used to identifiy the resolving parent
  171.      * set of attributes, if one is defined.
  172.      */
  173.     public static final Object ResolveAttribute = StyleConstants.ResolveAttribute;
  174.  
  175. }
  176.